package com.example.exp_3_javaweb;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.lang.reflect.Array;

@WebServlet(name = "infoservlet",value = "/infoservlet")
public class InfoServlet extends HttpServlet {
    public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException {
        request.setCharacterEncoding("utf-8");
        String name = request.getParameter("username");
        String[] hobby = request.getParameterValues("hobby");
        String gender = request.getParameter("gender").equals("0")?"男":"女";
        System.out.println("name:"+name);
        System.out.print("hobby:");
        for (int i = 0;i < hobby.length;i++) {
            System.out.print(hobby[i]+" ");
        }
        System.out.println();
        System.out.println("gender:"+gender);
    }
}
